<template>
	<view class="container">
			
			<swiper :style="{ height: swiperHeight }" circular :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
				<block v-for="(item, index) in adDatas" :key="index">
					<swiper-item class="u-flex u-row-center"  v-if="item != null" @click="clickImagesSwiper(index)">
						<image :style="{ height: bannerHeight }" :src="item.imageUrl" @click="detailCompany(item.owner)" mode="aspectFit"></image>
						<!-- <six-image size=150></six-image> -->
					</swiper-item>
				</block>
			</swiper>
			<view class="f-menu">
				<view @click="goto(item.url)" class="item" v-for="(item,index) in list" :key="index">
					<image :src="item.icon" class="picture" mode=""></image>
					<view class="title">
						{{item.name}}
					</view>
					<view class="explain">
						{{item.explain}}
					</view>
				</view>
			</view>
		<u-toast ref="uToast" />
			
	</view>
</template>

<script>
	export default {
		data() {
			return {
				adDatas:[],
				swiperHeight:'800px',
				bannerHeight:'500px',
				imageSwiper: [
					{
						id: '1',
						images: '/static/tabbar/gglbx.jpg' 
					},
					{
						id: '2',
						images: '/static/tabbar/gglbx.jpg' 
					},
					{
						id: '3',
						images: '/static/tabbar/gglbx.jpg'
					}
				],
				list:[{
					id:1,
					icon:this.$mAssetsPath.ztb,
					name:"招投标",
					explain:"我要发布招标信息",
					url:this.$mRoutesConfig.bidding
				},{
					id:2,
					icon:this.$mAssetsPath.gcxx,
					name:"工程信息",
					explain:"我要盘活工程资源",
					url:this.$mRoutesConfig.engineeringInformation
				},{
					id:3,
					icon:this.$mAssetsPath.zpxx,
					name:"招聘信息",
					explain:"我要发布招聘信息",
					url:this.$mRoutesConfig.recruitment
				},{
					id:4,
					icon:this.$mAssetsPath.zhxx,
					name:"智汇信息",
					explain:"我要信息创造价值",
					url:this.$mRoutesConfig.zhInformation
				},
				{
					id:5,
					icon:this.$mAssetsPath.zhtg,
					name:"智汇推广",
					explain:"我要进行商业合作推广",
					url:this.$mRoutesConfig.zhPromotion
				},{
					id:6,
					icon:this.$mAssetsPath.jwcz,
					name:"积微成著",
					explain:"我要管理我的时间",
					url:this.$mRoutesConfig.accumulate
				}],	
			}
		},
		onLoad(){		
			this.findfetchAd();
		},
		onShow(){	
			let userInfo = this.$store.state.userInfo;
			console.log(userInfo);
			if(userInfo.identityType != 1){				
				this.list[2] = {
					id:3,
					icon:this.$mAssetsPath.zpxx,
					name:"应聘信息",
					explain:"我要发布应聘信息",
					url:this.$mRoutesConfig.ApplyFor
				};
			}
			this.getfetchUserReviewed();
		// #ifdef APP-PLUS
			this.$tabbarView.$watch();
			// #endif
		},
		onHide() {
			// #ifdef APP-PLUS
			this.$tabbarView.$watch();
			// #endif
		},
		onReady() {
			var tempHeight = 800;
			var _me = this;
			uni.getSystemInfo({
				//获取手机屏幕高度信息，让swiper的高度和手机屏幕一样高
				success: function(res) {
					tempHeight = res.windowHeight;
					uni.createSelectorQuery()
						.select('.f-menu')
						.fields(
							{
								size: true,
								scrollOffset: true
							},
							data => {
								tempHeight -= data.height;
								_me.swiperHeight = tempHeight - 50 + 'px';
								_me.bannerHeight =  tempHeight - 100 + 'px';
							}
						)
						.exec();
				}
			});
		},
		methods: {			
			detailCompany(e){
				this.$mRouter.push({
					route:this.$mRoutesConfig.releaseNumber,
					query:{
						id:e
					}
				});
			},
			async getfetchUserReviewed(){
				if(uni.getStorageSync('token')){
					let result = await this.$apis.fetchUserReviewed();
					this.profileStatus = result.data;	
				}
			},
			async findfetchAd(type){
				let result = await this.$apis.fetchAd({type:0});
				this.adDatas = result.data;
			},	
			goto(url){
				if(uni.getStorageSync('token')){
					console.log("profileStatus",this.profileStatus);
					var that = this;
					if(this.profileStatus == 1){
						if(url != ''){					
							if(this.$store.state.userInfo.vipLevel < 1 && url == this.$mRoutesConfig.zhPromotion) {
								this.$refs.uToast.show({
									title: '会员专享，请升级',
									type: 'warning',
								})
								return;
							}else{
								this.$mRouter.push({
									route: url
								});
							}
						}else{
							this.$refs.uToast.show({
								title: '404，请联系客服',
								type: 'success',
							})
						}
					}else if(this.profileStatus == 2){
						uni.showModal({
							title:"提示",
							content:"资料审核中，通过以后才可以操作",
							success(res) {
								if(res.confirm){
									
								}
							}
						})
					}else{
						uni.showModal({
							title:"提示",
							content:"请先完善资料",
							confirmText:"立即完善",
							success(res) {
								if(res.confirm){
									if(that.$store.state.userInfo.identityType==1){	
										uni.navigateTo({
											url: '../user/myCompanyPage'
										});
									}else{
										uni.navigateTo({
											url: '../user/myHomePage'
										});
									}
								}
							}
						})
					}
				}else{
					uni.navigateTo({
						url: '../login/login'
					});
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.image-swiper{
		height: 100%;
	}
	.fgx{
		height: 1rpx;
		background-color: #DADFED;
	}
	.f-menu {
		position: relative;
		display: flex;flex-flow: wrap;padding:0 30rpx; padding-top:40rpx; justify-content: flex-start;
		&:after{
			position: absolute;
			content:' ';
			top:0;
			left:0;
			right:0;			
			height: 1rpx;
			background: #DADFED;
		}
		.item {width:33%;margin-bottom:30rpx;text-align: center;
			.title {
				padding:24rpx 0;
				font-weight: 700;
				font-size: 34rpx;
				color: #0D1D36;
			}
			.explain {
				margin: 0 auto;
				width:60%;
				color: #888D99;
			}
			image {
				width: 120rpx;
				height: 120rpx;
			}
		}
	}
	uni-swiper {height:400rpx;}
</style>
